#!/bin/bash

source head.sh





echo " 
<h1>学生信息表</h1>  
  
<table>  
    <tr>  
        <th>学号</th>  
        <th>班级号</th>  
        <th>姓名</th>  
        <th>年龄</th>  
    </tr> "
count=$(mysql -h10.10.10.81 -ujxadmin -p123456 jxcms -e "select count(1) from jx_stu " | grep -v count)

for ((i=1;i<=$count;i++));do
stu=$(mysql -h10.10.10.81 -ujxadmin -p123456 jxcms -e "select *from jx_stu" |grep -v id |sed -n $i"p")
id=$(echo $stu | awk -F " " '{print $1}')
class_id=$(echo $stu | awk -F " " '{print $2}')
name=$(echo $stu | awk -F " " '{print $3}')
age=$(echo $stu | awk -F " " '{print $4}')
echo " 
   <tr>  
        <td>$id</td>  
        <td>$class_id</td>  
        <td>$name</td>  
        <td>$age</td>  
    </tr> "
done  
echo "   <!-- 可以在这里继续添加更多学生信息 -->  "
source foot.sh

